<?php
$device_obj = new device();
$project_obj = new project();

$action_ary = array(
	'check' => 'app_act_checkno',  //获取参数
);

//action
//*+------------------------------------------------------------------------+*/


/**
 * 验证设备号是否注册后台
 */
function app_act_checkno(){
	global $device_obj,$project_obj;

	$news=array(
		array('color'=>"#FF0000",'text'=>"您的设备号还未注册"),
		array('color'=>"#000000",'text'=>"请联系服务商：重庆宏道拓土科技有限公司"),
		array('color'=>"#000000",'text'=>"联系电话：13368136787"),
	);

	$rtn = array('state'=>false);
	//得到设备信息
	$no = request('no');    //设备号
	$no=str_replace("-","",$no);
	//得到设备信息
	$device_info = $device_obj->device_info_by_no($no);
	if(!$device_info){
		$rtn['err'] = '';    //设备不存在
		$rtn['news']=$news;
		echo json_encode($rtn);
		return;
	}

	$bind_list = $device_obj->bind_list($device_info['id'],array('state'=>1));
	if(!$bind_list){
		//$rtn['code'] = 1105;    //设备没有指定项目
		$rtn['err'] = '';    //设备不存在
		$rtn['news']=$news;
		echo json_encode($rtn);
		return;
	}
	if(count($bind_list)>1){
		//$rtn['code'] = 1106;    //设备绑定了多个项目
		$rtn['err'] = '';    //设备不存在
		$rtn['news']=$news;
		echo json_encode($rtn);
		return;
	}
	$bind_info = $bind_list[0];
	//得到绑定的项目信息
	$project_info = $project_obj->info($bind_info['pid']);
	if($project_info['state']==2){
		//$rtn['code'] = 1201;    //项目已关闭
		$rtn['err'] = '';    //设备不存在
		$rtn['news']=$news;
		echo json_encode($rtn);
		return;
	}

    $rtn['state']=true;
	$rtn['news']=$news;
	echo json_encode($rtn);
}



//function
//*+------------------------------------------------------------------------+*/



